home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / guile-ii.src / guile-ii / guile-src / slib / vscm.init < prev    next >
Encoding:
Text File  |  1995-01-27  |  9.5 KB  |  307 lines

  1. ;;;"vscm.init" Configuration of *features* for VSCM    -*-scheme-*-
  2. ;Copyright (C) 1994 Aubrey Jaffer
  3. ;
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7. ;
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10. ;
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14. ;
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. ;;; From: Matthias Blume <blume@cs.Princeton.EDU>
  21. ;;; Date: Tue, 1 Mar 1994 11:42:31 -0500
  22. ;;; Disclaimer: The code below is only a quick hack.  If I find some
  23. ;;; time to spare I might get around to make some more things work.
  24. ;;; In particular, string ports could be made available without too
  25. ;;; much trouble.
  26.  
  27. ;;; You have to provide ``vscm.init'' as an explicit command line
  28. ;;; argument.  Since this is not very nice I would recommend the
  29. ;;; following installation procedure:
  30.  
  31. ;1. run scheme
  32. ;2. (load "vscm.init")
  33. ;3. (slib:dump "dumpfile")
  34. ;3. mv dumpfile place-where-vscm-standard-bootfile-resides, e.g.
  35. ;   mv dumpfile /usr/local/vscm/lib/scheme-boot
  36. ;   (In this case vscm should have been compiled with flag
  37. ;    -DDEFAULT_BOOTFILE='"/usr/local/vscm/lib/scheme-boot"'.  See
  38. ;    Makefile (definition of DDP) for details.)
  39.  
  40. (define (slib:dump dump-to-file)
  41.   (let ((args (dump dump-to-file)))
  42.     (if args
  43.     (begin
  44.       (display "[SLIB available]")
  45.       (newline)
  46.       (((mcm) 'toplevel) args))
  47.     (quit))))
  48.  
  49. ;;; Caveat: While playing with this code I discovered a nasty bug.
  50. ;;; (Something is wrong with my ``restore'' code -- it seems to break
  51. ;;; on 64 bit machines (not always, though).)  It works on MIPS, etc.
  52.  
  53. ;;; (software-type) should be set to the generic operating system type.
  54. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  55.  
  56. (define (software-type) 'UNIX)
  57.  
  58. ;;; (scheme-implementation-type) should return the name of the scheme
  59. ;;; implementation loading this file.
  60.  
  61. (define (scheme-implementation-type) 'Vscm)
  62.  
  63. ;;; (scheme-implementation-version) should return a string describing the
  64. ;;; version the scheme implementation loading this file.
  65.  
  66. (define (scheme-implementation-version) "?")
  67.  
  68. ;;; (implementation-vicinity) should be defined to be the pathname of
  69. ;;; the directory where any auxillary files to your Scheme
  70. ;;; implementation reside.
  71.  
  72. (define (implementation-vicinity)
  73.   (case (software-type)
  74.     ((UNIX)     "/usr/local/src/scheme/")
  75.     ((VMS)    "scheme$src:")
  76.     ((MS-DOS)    "C:\\scheme\\")))
  77.  
  78. ;;; (library-vicinity) should be defined to be the pathname of the
  79. ;;; directory where files of Scheme library functions reside.
  80.  
  81. (define library-vicinity
  82.   (let ((library-path
  83.      (or (getenv "SCHEME_LIBRARY_PATH")
  84.          ;; Uses this path if SCHEME_LIBRARY_PATH is not set.
  85.          (case (software-type)
  86.            ((UNIX) "/usr/local/lib/slib/")
  87.            ((VMS) "lib$scheme:")
  88.            ((MS-DOS) "C:\\SLIB\\")
  89.            (else "")))))
  90.     (lambda () library-path)))
  91.  
  92. ;;; *FEATURES* should be set to a list of symbols describing features
  93. ;;; of this implementation.  Suggestions for features are:
  94.  
  95. (define *features*
  96.       '(
  97.     source                ;can load scheme source files
  98.                     ;(slib:load-source "filename")
  99. ;    compiled            ;can load compiled files
  100.                     ;(slib:load-compiled "filename")
  101.     rev4-report            ;conforms to
  102. ;    rev3-report            ;conforms to
  103.     ieee-p1178            ;conforms to
  104. ;    sicp                ;runs code from Structure and
  105.                     ;Interpretation of Computer
  106.                     ;Programs by Abelson and Sussman.
  107.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  108.                     ;LIST->STRING, STRING-COPY,
  109.                     ;STRING-FILL!, LIST->VECTOR,
  110.                     ;VECTOR->LIST, and VECTOR-FILL!
  111.     rev3-procedures            ;LAST-PAIR, T, and NIL
  112. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  113.                     ;SUBSTRING-MOVE-RIGHT!,
  114.                     ;SUBSTRING-FILL!,
  115.                     ;STRING-NULL?, APPEND!, 1+,
  116.                     ;-1+, <?, <=?, =?, >?, >=?
  117.     multiarg/and-            ;/ and - can take more than 2 args.
  118.     multiarg-apply            ;APPLY can take more than 2 args.
  119.     rationalize
  120.     delay                ;has DELAY and FORCE
  121.     with-file            ;has WITH-INPUT-FROM-FILE and
  122.                     ;WITH-OUTPUT-FROM-FILE
  123. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  124.                     ;CALL-WITH-OUTPUT-STRING
  125. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  126. ;    char-ready?
  127. ;    macro                ;has R4RS high level macros
  128. ;    defmacro            ;has Common Lisp DEFMACRO
  129.     eval                ;SLIB:EVAL is single argument eval
  130. ;    record                ;has user defined data structures
  131.     values                ;proposed multiple values
  132. ;    dynamic-wind            ;proposed dynamic-wind
  133.     ieee-floating-point        ;conforms to
  134.     full-continuation        ;can return multiple times
  135. ;    object-hash            ;has OBJECT-HASH
  136.  
  137. ;    sort
  138. ;    queue                ;queues
  139. ;    pretty-print
  140.     object->string
  141. ;    format
  142. ;    trace                ;has macros: TRACE and UNTRACE
  143. ;    compiler            ;has (COMPILER)
  144. ;    ed                ;(ED) is editor
  145.     system                ;posix (system <string>)
  146.     getenv                ;posix (getenv <string>)
  147.     program-arguments        ;returns list of strings (argv)
  148. ;    Xwindows            ;X support
  149. ;    curses                ;screen management package
  150. ;    termcap                ;terminal description package
  151. ;    terminfo            ;sysV terminal description
  152.     ))
  153.  
  154. ;;; (OBJECT->STRING obj)  -- analogous to WRITE
  155. (define object->string string-write)
  156.  
  157. ;;; (PROGRAM-ARGUMENTS)
  158. ;;; 
  159. (define (program-arguments) command-line-arguments)
  160.  
  161. ;;; (OUTPUT-PORT-WIDTH <port>)
  162. (define (output-port-width . arg) 79)
  163.  
  164. ;;; (CURRENT-ERROR-PORT)
  165. (define current-error-port
  166.   (standard-port 2))
  167.  
  168. ;;; (TMPNAM) makes a temporary file name.
  169. (define tmpnam (let ((cntr 100))
  170.          (lambda () (set! cntr (+ 1 cntr))
  171.              (string-append "slib_" (number->string cntr)))))
  172.  
  173. ;;; (FILE-EXISTS? <string>)
  174. (define (file-exists? f)
  175.   (system (string-append "test -f " f)))
  176.  
  177. ;;; (DELETE-FILE <string>)
  178. (define (delete-file f)
  179.   (remove-file f))
  180.  
  181. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  182. (define force-output flush)
  183.  
  184. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  185. ;;; port versions of CALL-WITH-*PUT-FILE.
  186.  
  187. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  188. ;;; be returned by CHAR->INTEGER.
  189. (define char-code-limit 256)
  190.  
  191. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  192. (define most-positive-fixnum #x0fffffff)
  193.  
  194. ;;; Return argument
  195. (define (identity x) x)
  196.  
  197. ;;; If your implementation provides eval SLIB:EVAL is single argument
  198. ;;; eval using the top-level (user) environment.
  199. (define slib:eval eval)
  200.  
  201. ;;; If your implementation provides R4RS macros:
  202. (define macro:eval slib:eval)
  203. (define macro:load load)
  204.  
  205. (define *defmacros*
  206.   (list (cons 'defmacro
  207.           (lambda (name parms . body)
  208.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  209.                       *defmacros*))))))
  210. (define (defmacro? m) (and (assq m *defmacros*) #t))
  211.  
  212. (define (macroexpand-1 e)
  213.   (if (pair? e) (let ((a (car e)))
  214.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  215.                      (if a (apply (cdr a) (cdr e)) e))
  216.             (else e)))
  217.       e))
  218.  
  219. (define (macroexpand e)
  220.   (if (pair? e) (let ((a (car e)))
  221.           (cond ((symbol? a)
  222.              (set! a (assq a *defmacros*))
  223.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  224.             (else e)))
  225.       e))
  226.  
  227. (define gentemp
  228.   (let ((*gensym-counter* -1))
  229.     (lambda ()
  230.       (set! *gensym-counter* (+ *gensym-counter* 1))
  231.       (string->symbol
  232.        (string-append "slib:G" (number->string *gensym-counter*))))))
  233.  
  234. (define base:eval slib:eval)
  235. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  236. (define (defmacro:expand* x)
  237.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  238.  
  239. (define (defmacro:load <pathname>)
  240.   (slib:eval-load <pathname> defmacro:eval))
  241.  
  242. (define (slib:eval-load <pathname> evl)
  243.   (if (not (file-exists? <pathname>))
  244.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  245.   (call-with-input-file <pathname>
  246.     (lambda (port)
  247.       (let ((old-load-pathname *load-pathname*))
  248.     (set! *load-pathname* <pathname>)
  249.     (do ((o (read port) (read port)))
  250.         ((eof-object? o))
  251.       (evl o))
  252.     (set! *load-pathname* old-load-pathname)))))
  253.  
  254. ;;; define an error procedure for the library
  255. (define slib:error error)
  256.  
  257. ;;; define these as appropriate for your system.
  258. (define slib:tab #\Tab)
  259. (define slib:form-feed #\d12)
  260.  
  261. ;;; Support for older versions of Scheme.  Not enough code for its own file.
  262. (define (last-pair l) (if (pair? (cdr l)) (last-pair (cdr l)) l))
  263. (define t #t)
  264. (define nil #f)
  265.  
  266. ;;; Define these if your implementation's syntax can support it and if
  267. ;;; they are not already defined.
  268.  
  269. (define (1+ n) (+ n 1))
  270. (define (-1+ n) (+ n -1))
  271. (define 1- -1+)
  272.  
  273. (define in-vicinity string-append)
  274.  
  275. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  276. ;;; return if exitting not supported.
  277. (define slib:exit
  278.   (lambda args
  279.     (cond ((null? args) (quit))
  280.       ((eqv? #t (car args)) (quit))
  281.       ((eqv? #f (car args)) (quit 1))
  282.       (else (quit (car args))))))
  283.  
  284. ;;; Here for backward compatability
  285. (define scheme-file-suffix
  286.   (let ((suffix (case (software-type)
  287.           ((NOSVE) "_scm")
  288.           (else ".scm"))))
  289.     (lambda () suffix)))
  290.  
  291. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  292. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  293.  
  294. (define (slib:load-source f) (load (string-append f (scheme-file-suffix))))
  295.  
  296. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  297. ;;; by compiling "foo.scm" if this implementation can compile files.
  298. ;;; See feature 'COMPILED.
  299.  
  300. (define slib:load-compiled load)
  301.  
  302. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  303.  
  304. (define slib:load slib:load-source)
  305.  
  306. (slib:load (in-vicinity (library-vicinity) "require"))
  307.